#pragma once

class ComPorts
{
	public:
	HWND hMainWnd;
	
	
	COMMTIMEOUTS CommTimeouts;

	bool SetTimeout();
	bool SetBitrate();
	bool DTRDisable();
	bool DTREnable();
	bool RTSDisable();
	bool RTSEnable();
	
	inline void SDA_output();
	inline void SDA_input();
	inline void SDA_low();
	inline void SDA_high();
	inline void SCL_low();
	inline void SCL_high();


	//Zeiger auf Port
	HANDLE hPort;
	DWORD dwError;
	DCB PortDCB;


	bool Activated;
	ComPorts(HWND hMainWnd);
	~ComPorts(void);

	bool WriteByte(BYTE Byte);
	BYTE ReadByte();
	
	unsigned char SDA_value();
	void I2C_wait();
	void I2C_start();
	void I2C_stop();
	void I2C_clock();
	void I2C_send_nack();
	void I2C_send_ack();
	bool I2C_read_ack();
	byte I2C_rx_byte();
	void I2C_tx_byte(unsigned char B);

};
